//
// Decompiled by Jadx - 1167ms
//
package gc;

import android.app.Activity;
import android.widget.EditText;
import cc.s;
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
import fi.b;
import fi.e;
import fi.w;
import fn.j;
import fn.y;
import gc.ag;
import gc.ck;
import gj.k;
import gj.r;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import me.plusne.common.Json.JsonHookStatic;
import org.luckypray.dexkit.result.AnnotationData;
import org.luckypray.dexkit.result.AnnotationElementData;
import org.luckypray.dexkit.result.ClassData;
import org.luckypray.dexkit.result.FieldData;
import org.luckypray.dexkit.result.FieldDataList;
import p.a;
import r.f;

public final class af implements Runnable {
    public final int a;
    public final Object b;
    public final Object c;
    public final Object d;

    public af(Object obj, Object obj2, Object obj3, int i) {
        this.a = i;
        this.b = obj;
        this.c = obj2;
        this.d = obj3;
    }

    @Override
    public final void run() {
        StringBuilder sb;
        String str;
        f i;
        String str2;
        StringBuilder sb2;
        String str3;
        String s;
        Object obj;
        FieldDataList publishCommentFieldDataList;
        int i2;
        FieldDataList publishCommentFieldDataList2;
        int i3;
        String str4;
        int i4 = this.a;
        Object obj2 = this.d;
        Object obj3 = this.c;
        Object obj4 = this.b;
        switch (i4) {
            case 0:
                ag agVar = (ag) obj4;
                ag.b bVar = (ag.b) obj3;
                Object[] objArr = (Object[]) obj2;
                Object aa = j.aa(agVar.cr, "execute");
                if (aa == null) {
                    j.bi(new Object[]{"response is Null"});
                    return;
                }
                String str5 = (String) j.aa(j.aa(aa, agVar.cu(aa)), "string");
                JsonHookStatic jsonHookStatic = y.by;
                if (jsonHookStatic.getActivity() == null) {
                    jsonHookStatic.getMainHandler().post(new ad(bVar, str5, objArr, 0));
                    return;
                } else {
                    jsonHookStatic.getActivity().runOnUiThread(new ad(bVar, str5, objArr, 1));
                    return;
                }
            case 1:
                ck.a aVar = (ck.a) obj4;
                int i5 = ck.a.a;
                aVar.getClass();
                w wVar = new w(y.by.getActivity());
                wVar.bj(fi.e.LIST_ITEM);
                wVar.bi("替换瞬间语音");
                b bVar2 = new b();
                bVar2.b("替换瞬间语音为本地文件");
                bVar2.b("替换语音为收藏语音");
                wVar.ay(bVar2);
                wVar.ae = new cj(aVar, obj3, (XC_MethodHook.MethodHookParam) obj2);
                wVar.bk();
                return;
            case 2:
                String str6 = (String) obj4;
                String str7 = (String) obj3;
                JsonHookStatic jsonHookStatic2 = y.by;
                String str8 = "@{author}\n{desc}\n";
                if (jsonHookStatic2.getPre().equals("TK")) {
                    Class ak = j.ak("com.ss.android.ugc.aweme.comment.commentlist.api.CommentApi");
                    if (ak == null) {
                        str4 = "";
                    } else {
                        str4 = ak.getDeclaredFields()[0].getName();
                    }
                    Object ab = j.ab(j.ab(XposedHelpers.getStaticObjectField(ak, str4), "create", new Object[]{j.ak("com.ss.android.ugc.aweme.comment.commentlist.api.CommentApi$RealApi")}), "publishCommentCheck", new Object[]{str6, str7, "", "[]", "", 0, "", 0, 0, "", 0, 0});
                    if (ab != null) {
                        Object aa2 = j.aa(ab, "get");
                        if (aa2 != null) {
                            int intField = XposedHelpers.getIntField(aa2, "status_code");
                            if (j.ae("isAutoTip")) {
                                if (intField == 0) {
                                    i = f.i();
                                    sb2 = new StringBuilder();
                                    s = j.s(obj2, "@{author}\n{desc}\n");
                                    sb2.append(s);
                                    str3 = "评论成功[";
                                    sb2.append(str3);
                                } else {
                                    i = f.i();
                                    i.j();
                                    sb2 = new StringBuilder();
                                    sb2.append(j.s(obj2, "@{author}\n{desc}\n"));
                                    sb2.append("评论失败[");
                                }
                            } else {
                                return;
                            }
                        }
                        i = f.i();
                        i.j();
                        str2 = "评论失败,未知错误1";
                        i.l(str2);
                        return;
                    }
                    i = f.i();
                    i.j();
                    str2 = "评论失败,未知错误";
                    i.l(str2);
                    return;
                }
                Object ab2 = j.ab(XposedHelpers.getStaticObjectField(j.ak(jsonHookStatic2.getDy().getApiClass().getDeclaredClassName()), jsonHookStatic2.getDy().getApiClass().getFieldName()), "create", new Object[]{j.ak(jsonHookStatic2.getDy().getPublishCommentStr())});
                Object ad = j.ad(j.ak(jsonHookStatic2.getDy().getMethodData_get().getClassName()), jsonHookStatic2.getDy().getMethodData_get().getMethodName(), new Object[0]);
                if (jsonHookStatic2.getDy().getMethodData_get().getReturnType() != null) {
                    ArrayList arrayList = new ArrayList();
                    List paramAnnotations = jsonHookStatic2.getDy().getParamAnnotations();
                    int i6 = 0;
                    while (i6 < paramAnnotations.size()) {
                        List list = paramAnnotations;
                        String stringValue = ((AnnotationElementData) ((AnnotationData) ((List) paramAnnotations.get(i6)).get(0)).getElements().get(0)).getValue().stringValue();
                        JsonHookStatic jsonHookStatic3 = y.by;
                        Object obj5 = obj2;
                        String name = ((ClassData) jsonHookStatic3.getDy().getPublishCommentClassDataList().get(i6)).getName();
                        String str9 = str8;
                        if (Objects.equals(stringValue, "aweme_id")) {
                            arrayList.add(str6);
                        } else if (Objects.equals(stringValue, "text")) {
                            arrayList.add(str7);
                        } else if (Objects.equals(stringValue, "text_extra") || Objects.equals(stringValue, "city")) {
                            arrayList.add("[]");
                        } else {
                            if (Objects.equals(stringValue, "publish_scene")) {
                                obj = "comment_list";
                            } else if (Objects.equals(stringValue, "need_risk_check")) {
                                obj = 1;
                            } else if (Objects.equals(stringValue, "is_commerce")) {
                                obj = "0";
                            } else if (Objects.equals(stringValue, "enter_from")) {
                                obj = "homepage_hot";
                            } else {
                                if (Objects.equals(stringValue, "click_comment_time")) {
                                    publishCommentFieldDataList2 = jsonHookStatic3.getDy().getPublishCommentFieldDataList();
                                    i3 = 0;
                                } else {
                                    if (Objects.equals(stringValue, "click_comment_pct")) {
                                        publishCommentFieldDataList = jsonHookStatic3.getDy().getPublishCommentFieldDataList();
                                        i2 = 1;
                                    } else if (Objects.equals(stringValue, "video_offset_time")) {
                                        publishCommentFieldDataList2 = jsonHookStatic3.getDy().getPublishCommentFieldDataList();
                                        i3 = 2;
                                    } else if (Objects.equals(stringValue, "video_offset_pct")) {
                                        publishCommentFieldDataList = jsonHookStatic3.getDy().getPublishCommentFieldDataList();
                                        i2 = 3;
                                    } else if (Objects.equals(name, "int") || Objects.equals(name, "long") || Objects.equals(name, "float") || Objects.equals(name, "double")) {
                                        arrayList.add(0);
                                    } else if (Objects.equals(name, String.class.getName())) {
                                        arrayList.add("");
                                    } else {
                                        obj = null;
                                    }
                                    obj = Float.valueOf(XposedHelpers.getFloatField(ad, ((FieldData) publishCommentFieldDataList.get(i2)).getFieldName()));
                                }
                                obj = Long.valueOf(XposedHelpers.getLongField(ad, ((FieldData) publishCommentFieldDataList2.get(i3)).getFieldName()));
                            }
                            arrayList.add(obj);
                        }
                        i6++;
                        paramAnnotations = list;
                        str8 = str9;
                        obj2 = obj5;
                    }
                    Object obj6 = obj2;
                    String str10 = str8;
                    Object ab3 = j.ab(ab2, "publishComment", arrayList.toArray());
                    if (ab3 != null) {
                        Object aa3 = j.aa(ab3, "get");
                        if (aa3 != null) {
                            int intField2 = XposedHelpers.getIntField(aa3, "status_code");
                            if (j.ae("isAutoTip")) {
                                if (intField2 == 0) {
                                    i = f.i();
                                    sb2 = new StringBuilder();
                                    s = j.s(obj6, str10);
                                    sb2.append(s);
                                    str3 = "评论成功[";
                                    sb2.append(str3);
                                } else {
                                    i = f.i();
                                    i.j();
                                    sb2 = new StringBuilder();
                                    sb2.append(j.s(obj6, str10));
                                    str3 = "评论失败[";
                                    sb2.append(str3);
                                }
                            } else {
                                return;
                            }
                        }
                        i = f.i();
                        i.j();
                        str2 = "评论失败,未知错误1";
                        i.l(str2);
                        return;
                    }
                    i = f.i();
                    i.j();
                    str2 = "评论失败,未知错误";
                    i.l(str2);
                    return;
                }
                i = f.i();
                i.j();
                str2 = "获取参数错误";
                i.l(str2);
                return;
                str2 = androidx.activity.b.j(sb2, str7, "]");
                i.l(str2);
                return;
            default:
                k kVar = (k) obj4;
                s sVar = (s) obj3;
                w wVar2 = (w) obj2;
                Activity activity = kVar.d;
                dg.b bVar3 = new dg.b();
                String obj7 = ((EditText) sVar.f).getText().toString();
                EditText editText = sVar.d;
                bVar3.f(obj7, editText.getText().toString());
                EditText editText2 = sVar.e;
                if (editText2.getText().toString().endsWith("/")) {
                    sb = new StringBuilder();
                    sb.append(editText2.getText().toString());
                    str = "PlusNE";
                } else {
                    sb = new StringBuilder();
                    sb.append(editText2.getText().toString());
                    str = "/PlusNE";
                }
                sb.append(str);
                String sb3 = sb.toString();
                try {
                    if (!bVar3.c(sb3)) {
                        bVar3.b(sb3);
                    }
                    fi.y.d();
                    if (bVar3.c(sb3)) {
                        fi.y.e(activity);
                        a.b(((EditText) sVar.f).getText().toString(), editText.getText().toString(), editText2.getText().toString(), new r(kVar, activity, sVar, wVar2));
                        return;
                    } else {
                        f fVar = new f(activity);
                        fVar.j();
                        fVar.l("无法创建文件夹,请检查参数是否填写正确");
                        return;
                    }
                } catch (IOException | IllegalArgumentException e) {
                    fi.y.d();
                    e.printStackTrace();
                    f fVar2 = new f(activity);
                    fVar2.j();
                    fVar2.l("请检查参数是否填写正确:" + e.getMessage());
                    return;
                }
        }
    }
}
